from building import *

cwd  = GetCurrentDir()
src  = Split('''
board.c
drv_clock.c
drv_spi.c
''')

if GetDepend(['BSP_USING_GPIO']):
    src += ['drv_gpio.c']

if GetDepend(['BSP_USING_I2C2']):
    src += ['drv_i2c.c']

if GetDepend(['BSP_USING_TOUCH']):
    src += ['drv_touch.c']
    src += ['drv_gt911.c']

if GetDepend(['BSP_USING_UART0']) or GetDepend(['BSP_USING_UART1']) or GetDepend(['BSP_USING_UART2']):
    src += ['drv_uart.c']

if GetDepend(['BSP_USING_WDT']):
    src += ['drv_watchdog.c']

if GetDepend('BSP_USING_RTC'):
    src += ['drv_rtc.c']

if GetDepend('BSP_USING_PWM'):
    src += ['drv_pwm.c']

if GetDepend('BSP_USING_LCD'):
    src += ['drv_lcd.c']    

list = os.listdir(cwd)
CPPPATH = [cwd]
objs = []

group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)

for d in list:
    path = os.path.join(cwd, d)
    if os.path.isfile(os.path.join(path, 'SConscript')):
        objs = objs + SConscript(os.path.join(d, 'SConscript'))
objs = objs + group
Return('objs')
